                                                                                                                                            package com.norteksoft.struts.web.ec;

import javax.servlet.http.HttpServletRequest;

import org.extremecomponents.table.limit.Limit;

import com.norteksoft.struts.Constants;

public class Page {
	private String query;
	private int start;
	public Page(String query){
		this.query=query;
	}
	public String getQuery() {
		return query;
	}
	public int getStart() {
		return start;
	}
	public void prepare(String tableId,int totalRows,HttpServletRequest request){
		Limit limit=PaginationUtil.getLimit(tableId, request);
		System.out.println("******************limit.getPage():"+limit.getPage());
		System.out.println("******************limit.getTotalRows():"+limit.getTotalRows());
		System.out.println("******************limit.getCurrentRowsDisplayed():"+limit.getCurrentRowsDisplayed());
		limit.setRowAttributes(totalRows, Constants.PAGE_SIZE);
		System.out.println("******************2limit.getCurrentRowsDisplayed():"+limit.getCurrentRowsDisplayed());
		query=PaginationUtil.sortQuery(limit.getSort(), query);
		start=(limit.getPage()-1)*limit.getCurrentRowsDisplayed();
		request.setAttribute("totalRows",new Integer(totalRows));//extremecomponent必须设置这个属性
	}
	public void prepare(int totalRows,HttpServletRequest request){
		prepare(Constants.TABLE_ID,totalRows,request);
	}
}
